#include "app_dht11.h"
#include "bsp_dht11.h"
#include "bsp_delay.h"

uint8_t DHT11_data[5] = {0};  
 

unsigned char DHT11_READ_DATA(void)
{
    uint8_t i;
    
    DHT11_START();                                  
    
    if(DHT11_Check())                                
    {  
        while(!DHT11_READ_IO);                    
        while(DHT11_READ_IO);                       
        
        for(i=0; i<5; i++)
        {                        
            DHT11_data[i] = DHT11_READ_BYTE();    
        }
        
        if(DHT11_data[0] + DHT11_data[1] + DHT11_data[2] + DHT11_data[3] == DHT11_data[4])
        {
            return 1;                            
        }
        else
        {
            return 0;                             
        }
    }
    else                                          
    {
        return 2;
    }
}
 




